function saveCSV() {
    const table = document.getElementById('csvTable');
    const data = [];
    for (const row of table.rows) {
        const rowData = [];
        for (const cell of row.cells) {
            rowData.push(cell.innerText);
        }
        data.push(rowData);
    }

    fetch('/update', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({ data: data }),
    })
    .then(response => response.json())
    .then(response => {
        if (response.success) {
            alert('CSV Saved Successfully!');
        } else {
            alert('Error saving CSV.');
        }
    });
}